//
//  HWxiaohaofenzutakuangView.m
//  HWanGame
//
//  Created by 陈道斌 on 2020/11/17.
//  Copyright © 2020 Chendaobin. All rights reserved.
//

#import "HWxiaohaofenzutakuangView.h"

@interface HWxiaohaofenzutakuangView()
@property(strong,nonatomic) UIImageView *icoimageview;
@property(strong,nonatomic) UILabel *miashuLabel;
@property(strong,nonatomic) UILabel *xiaohaogeshuLabel;

@property(strong,nonatomic) UIImageView *jiantouImgae;


@end


@implementation HWxiaohaofenzutakuangView

+ (instancetype)headFooterViewWithTableview:(UITableView *)tableview {
    
    HWxiaohaofenzutakuangView *view = [tableview dequeueReusableHeaderFooterViewWithIdentifier:NSStringFromClass([HWxiaohaofenzutakuangView class])];

      if (view == nil) {
          view = [[HWxiaohaofenzutakuangView alloc]initWithReuseIdentifier:NSStringFromClass([HWxiaohaofenzutakuangView class])];
      }
   //   view.backgroundColor = [UIColor yellowColor];
      return view;
    
}


- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self =  [super initWithReuseIdentifier:reuseIdentifier]) {
   
        [self setupUI];
        
        
        
    }
    
    
    
    return self;
}



- (void)layoutSubviews {
    

    
    [super layoutSubviews];

}



- (void)setupUI {
    
    
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.icoimageview  = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 52, 52)];
    self.icoimageview.layer.cornerRadius = 8;
    self.icoimageview.layer.masksToBounds = YES;
    self.icoimageview.backgroundColor  = [UIColor redColor];
    [self.contentView addSubview:self.icoimageview];
    
    
    self.contentView.backgroundColor = [UIColor whiteColor];

               self.miashuLabel  = [[UILabel alloc]initWithFrame:CGRectMake(self.icoimageview.right+10, 20, 200, 25)];
               self.miashuLabel.text = @"1";
               self.miashuLabel.font = [UIFont systemFontOfSize:17];
               self.miashuLabel.textColor = RGB(68,68,68);
               self.miashuLabel.numberOfLines = 2;
               self.miashuLabel.textAlignment = NSTextAlignmentLeft;
                self.miashuLabel.userInteractionEnabled =YES;
               [self.contentView addSubview:self.miashuLabel];
    
    
//              UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dianjizhankai)];
//              [self.datelabel addGestureRecognizer:tap1];
//
    
    
    
    
                 self.xiaohaogeshuLabel  = [[UILabel alloc]initWithFrame:CGRectMake(self.icoimageview.right+10, self.miashuLabel.bottom+12, 200, 17)];
                  self.xiaohaogeshuLabel.text = @"1";
                  self.xiaohaogeshuLabel.font = [UIFont systemFontOfSize:12];
                  self.xiaohaogeshuLabel.textColor = RGB(136,136,136);
                  self.xiaohaogeshuLabel.numberOfLines = 2;
                  self.xiaohaogeshuLabel.textAlignment = NSTextAlignmentLeft;
                   self.xiaohaogeshuLabel.userInteractionEnabled =YES;
                  [self.contentView addSubview:self.xiaohaogeshuLabel];
    
    
    self.jiantouImgae  = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-16-20,  40, 16, 16)];
    self.jiantouImgae.image = [UIImage imageNamed:@"jiantouzuobian"];
    [self.contentView addSubview:self.jiantouImgae];
    self.contentView.userInteractionEnabled = YES;
    
    
    UITapGestureRecognizer *tap  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dianjxiaohao)];
    [self.contentView addGestureRecognizer:tap];
    
       
    
    
}

-(void)setDataModel:(HWXiaoHaoGroupModel *)dataModel {
    
    _dataModel = dataModel;
    
    
    [self.icoimageview sd_setImageWithURL:[NSURL URLWithString:dataModel.icon] placeholderImage:nil];
    self.miashuLabel.text = [NSString stringWithFormat:@"%@",dataModel.name];
    self.xiaohaogeshuLabel.text = [NSString stringWithFormat:@"%d小号",dataModel.small.count];
    
    
    
    
}


- (void)dianjxiaohao {
    
    
    
    
    self.dataModel.visible = !self.dataModel.isVisible;
    
    
    if (self.dataModel.small.count > 0) {
         
     } else {
         
         [MBProgressHUD showError:@"该小号没有玩过游戏"];

     }
    
    
    
    [self.delegate HWxiaohaofenzutakuangViewdianj:self.dataModel];
    
}








@end



